<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>事件</title>
  <style>
    #div1{
      width: 400px;
      height: 400px;
      border: 1px solid red;
    }
    #div2{
      width: 200px;
      height: 200px;
      border: 1px solid blue;
    }
  </style>
</head>
<body>
  <!-- 事件的冒泡
  父子包含,先触发的子类,父类默认触发
  -->
  <div id="div1" onclick="myclick(event)" >
    <div id="div2" onclick="myclick(event)"  >
  
    </div>
  </div>
  
  <div id="div2"  >事件监听</div>
  <a href="#" onclick="myclick(event)"  > a标签默认事件</a>
  <script>
    function myclick(event) {
      console.log("点击事件",event)
      console.log("事件触发的类型",event.type)
      // 0 左键,1 中间,2 右键
      console.log("单机的键",event.button)
      console.log("触发事件的标签",event.target)
      // 谁处理的mouseover
      // console.log("响应事件的标签",event.currentTarget)
      // 阻止冒泡
      event.stopPropagation()
      // 阻止默认事件 a标签的跳转,submit的自动的提交
      event.preventDefault()
    }
  </script>
</body>
</html>